<template>
	<view class="mine-container" :style="{height: `${windowHeight}px`}">
		<!--顶部个人信息栏-->
		<!--  <view class="header-section">
			<view class="flex padding justify-between">
				<view class="flex align-center">
					<view v-if="!avatar" class="cu-avatar xl round bg-white">
						<view class="iconfont icon-people text-gray icon"></view>

					</view>
					<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round"
						mode="widthFix">
					</image>
					<view v-if="!name" @click="handleToLogin" class="login-tip">
						点击登录
					</view>
					<view v-if="name" @click="handleToInfo" class="user-info">
						<view class="u_title">
							用户名：{{ name }}
						</view>
					</view>
				</view>
				<view @click="handleToInfo" class="flex align-center">
					<text>个人信息</text>
					<view class="iconfont icon-right"></view>
				</view>
			</view>
		</view> -->
		<view class="header-section">
			<view class="flex  justify-between">
				<view class="flex align-center">
					<u-avatar @click="goAvatar" size="60" :src="avatar"></u-avatar>
					<!-- <image @click="goAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix"> -->
					</image>
					<view class="user-info" @click="handleToInfo">
						<view class="u_title ellipsis" style="display: flex;">
							<view class="f18">
								{{userInfo.userName}}
							</view>
							<!-- v-if="userInfo.breachNum== 3" -->
							<view class="" v-if="countNumber >= 3" style="background-image: url('/static/images/threenON.png'); background-size: 100% 100%; width: 165px;height: 30px;margin-left: 10px;font-size: 15px;text-align: center;color: #614509;">
								<!-- <image  src="/static/images/threenON.png" mode="" style="width: 180px;height: 30px;margin-left: 10px;"></image> -->
							  您已经有{{countNumber}}次未取餐
							</view>
						</view>
						<view class="flex_align_conter u_text">
							<view class="f18">
								职务 {{roleGroup}}
							</view>
							<!-- 			<view class="" style="margin-left: 30rpx;">
								工号 663524788522
							</view> -->
						</view>
					</view>
				</view>

			</view>
		</view>

		<view class="content-section">
			<view class="mine-actions ">
				<view class="action-item" @click="">
					<view class="n f18">
						{{orderNum.onOrderNum}}
					</view>
					<view class="text  f34">本周已订餐</view>
					<view class="f18">
						天数
					</view>
				</view>
				<view class="action-item" @click="">
					<view class="n f34">
						{{orderNum.noOrderNum}}
					</view>
					<view class="text f34">本周未订餐</view>
					<view class="f18">
						天数
					</view>
				</view>
				<view class="action-item" @click="">
					<view class="n f34">
						{{orderNum.allOrderNum}}
					</view>
					<text class="text f34">累计订餐</text>
					<view class="f18">
						天数
					</view>
				</view>
			</view>

			<view class="menu-list">
				<!-- <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
					<view class="menu-item-box">
						<view class="iconfont icon-user menu-icon"></view>
						<view>编辑资料</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow" @click="handleHelp">
					<view class="menu-item-box">
						<view class="iconfont icon-help menu-icon"></view>
						<view>常见问题</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow" @click="handleAbout">
					<view class="menu-item-box">
						<view class="iconfont icon-aixin menu-icon"></view>
						<view>关于我们</view>
					</view>
				</view> -->
				<view class="list-cell list-cell-arrow" >
					<view class="menu-item-box" @click="goNotice">
						<image class="menu-img" src="@/static/images/icons/mine_5.svg" mode=""></image>
						<view class="f18">我的通知</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow" >
					<view class="menu-item-box" @click="handleToInfo">
						<image class="menu-img" src="@/static/images/icons/mine_6.svg" mode=""></image>
						<view class="f18">我的信息</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow" >
					<view class="menu-item-box" @click="goMyOrder">
						<image class="menu-img" src="@/static/images/icons/mine_3.svg" mode=""></image>
						<view class="f18">我的订单</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow">
					<view class="menu-item-box" @click="handleToSetting">
						<image class="menu-img" src="@/static/images/icons/mine_2.svg" mode=""></image>
						<view class="f18">设置</view>
					</view>
				</view>
				<!-- 			<view class="list-cell list-cell-arrow" @click="goAdmin">
					<view class="menu-item-box">
						<image class="menu-img" src="@/static/images/icons/mine_4.svg" mode=""></image>
						<view>我的客服</view>
					</view>
				</view> -->
			</view>

		</view>
		<navigationBar tabbarIndex="3"></navigationBar>
	</view>
</template>

<script>
	import {
		getUserProfile
	} from "@/api/system/user"
	import {
		getOrderNumAPI,
		getCbreachdy
	} from '@/api/index.js'
	import navigationBar from '@/components/common/navigationBar.vue'
	export default {
		data() {
			return {
				countNumber:0,
				orderNum: {},
				roleGroup: '',
				userInfo: this.$store.state.user.userInfo,
				name: this.$store.state.user.name
			}
		},
		components: {
			navigationBar
		},
		computed: {
			avatar() {
				return this.$store.state.user.avatar
			},
			windowHeight() {
				return uni.getSystemInfoSync().windowHeight - 50
			}
		},
		onLoad() {
			console.log(this.$store.state.user.userInfo.breachNum)
			this.getUser()
			this.getOrderNum()
			this.countNum()
		},
		methods: {
			async countNum(){
				const res = await getCbreachdy(this.userInfo.userId)
				console.log(res.data)
				this.countNumber = res.data
			},
			
			async getOrderNum() {
				const res = await getOrderNumAPI(this.userInfo.userId)
				this.orderNum = res.data
			},
			goAvatar() {
				this.$tab.navigateTo('/pages/mine/avatar/index')
			},
			getUser() {
				getUserProfile().then(response => {
					// this.user = response.data
					this.roleGroup = response.roleGroup
					// this.postGroup = response.postGroup
				})
			},
			goNotice() {
				this.$tab.navigateTo('/subpackages/user/pages/order/notice')
			},
			goMyOrder() {
				// redirectTo
				this.$tab.redirectTo('/pages/order/order')
			},
			goAdmin() {
				// uni.reLaunch({
				// 	url: '/subpackages/admin/pages/index/index' // 对应分包的路径
				// });
			},
			handleToInfo() {
				this.$tab.navigateTo('/pages/mine/info/index')
			},
			handleToEditInfo() {
				this.$tab.navigateTo('/pages/mine/info/edit')
			},
			handleToSetting() {
				uni.navigateTo({url:'/pages/mine/setting/index'})
			},
			handleToLogin() {
				this.$tab.reLaunch('/pages/login')
			},
			handleToAvatar() {
				this.$tab.navigateTo('/pages/mine/avatar/index')
			},
			handleHelp() {
				this.$tab.navigateTo('/pages/mine/help/index')
			},
			handleAbout() {
				this.$tab.navigateTo('/pages/mine/about/index')
			},
			handleJiaoLiuQun() {
				this.$modal.showToast('QQ群：①133713780(满)、②146013835(满)、③189091635')
			},
			handleBuilding() {
				this.$modal.showToast('模块建设中~')
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f5f6f7;
	}

	.mine-container {
		width: 100%;
		height: 100%;


		.header-section {
			width: 100%;
			height: 380rpx;
			padding: 120rpx 30rpx 90rpx;
			// height: 500px;
			// background-color: #3c96f3;
			// background-image: url('/static/images/icons/mine_1.png');
			// background-image: url('/static/images/icons/confirmOrder_1.png');
			background-image: url('https://beihai-food.oss-cn-beijing.aliyuncs.com/08.png');
			background-repeat: no-repeat;
			background-size: 100%;
			// color: white;

			.login-tip {
				font-size: 18px;
				margin-left: 10px;
			}

			.cu-avatar {
				// width: 80rpx;
				// height: 80rpx;
				border: 2px solid #eaeaea;

				.icon {
					font-size: 40px;
				}
			}

			.user-info {
				width: 500rpx;
				margin-left: 20rpx;

				.u_title {
					color: #190300;
					font-size: 36rpx;
					line-height: 30px;
				}

				.u_text {
					margin-top: 14rpx;
					font-size: 24rpx;
					color: #848484;
				}
			}
		}

		.content-section {
			position: relative;
			top: -130rpx;

			.mine-actions {
				display: flex;
				justify-content: space-around;
				margin: 20rpx;
				padding: 40rpx 0px;
				border-radius: 8px;
				background-color: white;
				text-align: center;

				.action-item {
					color: #3D3D3D;

					.n {

						font-size: 48rpx;
					}

					.icon {
						font-size: 28px;
					}

					.text {
						display: block;
						font-size: 28rpx;
						// margin: 8px 0px;
						margin-top: 24rpx;
					}
				}
			}

			.list-cell-arrow {
				margin-bottom: 20rpx;
				border-radius: 16rpx;
			}

			.menu-img {
				width: 40rpx;
				height: 40rpx;
				margin-right: 16rpx;
			}
		}
	}
</style>